<template>
    <el-table :data="data" style="width: 100%">
        <el-table-column prop="id" label="ID" width="180" />
        <el-table-column prop="title" label="试卷名称" width="180" />
        <el-table-column prop="start_time" label="开始时间" width="180" />
        <el-table-column prop="end_time" label="结束时间" width="180" />
        <el-table-column>
            <template #default="scope">
                <el-button type="primary" bg text @click="view_info(scope.row.id)">查看试卷详情</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script setup>
import { ref, onMounted } from "vue"
import axios from '@/utils/http.js'
import formatTime from '@/utils/formattime.js'
import { useRouter } from 'vue-router'
let router = useRouter()
let data = ref([])
onMounted(() => {
    Paper_list()
})
function Paper_list() {
    axios({
        url: 'examination/generate/',
        method: 'GET'
    }).then(res => {
        data.value = res.data.data
        for (var i = 0; i < data.value.length; i++) {
            data.value[i].start_time = formatTime(data.value[i].start_time)
            data.value[i].end_time = formatTime(data.value[i].end_time)
        }
    })
}

function view_info(id) {
    router.push({
        path: '/view_result',
        query: {
            id: id
        }
    })
}
</script>

<style scoped>
.center-text {
    display: inline-block;
    margin-right: 10px
}
</style>